package com.cloudeye.logtest;

import com.cloudeye.logtest.com.cloudeye.logtest.event.TestRunListener;
import com.cloudeye.logtest.com.cloudeyhe.logtest.actuator.CostomActuatorEndpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

import javax.annotation.PostConstruct;

@SpringBootApplication
public class LogTestApplication {

    private static final Logger logger = LoggerFactory.getLogger(LogTestApplication.class);

    @PostConstruct
    public void logSomething(){
        logger.debug("debug something");
        logger.info("info something");
    }

    @Bean
    public CostomActuatorEndpoint costomActuatorEndpoint(){
        return new CostomActuatorEndpoint();
    }
    public static void main(String[] args) {
        SpringApplication  application = new SpringApplication(LogTestApplication.class);
        application.addListeners(new TestRunListener());
        ConfigurableApplicationContext applicationContext = application.run(args);
        String sqlDb = applicationContext.getEnvironment().getProperty("sql.db");
        logger.info("sql----db:{}",sqlDb);
    }
}
